<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
ka-Map Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="kaQuery.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b>ka-Map</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>kaQuery.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'kaQuery.js'<BR/><BR/>
	
</p>

<hr>



<!-- ========== METHOD SUMMARY =========== -->

	<a name="method_summary"><!-- --></a>
	<table border="1" cellpadding="3" cellspacing="0" width="100%">
		<tr bgcolor="#CCCCFF" class="TableHeadingColor">
			<td colspan=2>
				<font size="+2">
					<b>Method Summary</b>
				</font>
			</td>
		</tr>
	
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;Object</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!myQuery">myQuery</a></b>( eventID, queryType, coords ) * { * alert( "QUERY: " + queryType + " " + coords ); * } * * Querying actually does nothing except generate a KAMAP_QUERY event with * the query type and coordinates passed as parameters to the event handler * * Signature of the query event handler is: * * function myQueryHandler( eventID, queryType, queryCoords ) * * eventID: int, KAMAP_QUERY * * queryType: int, one of KAMAP_POINT_QUERY or KAMAP_RECT_QUERY * * queryCoords: array, array of two or four floating point coordinates * depending on the query type * * You can affect the style of the zoom box by changing oQuery.domObj.style as * you would with any other HTML element (it's a div). * *****************************************************************************/ var KAMAP_QUERY = gnLastEventId ++; var KAMAP_POINT_QUERY = 0; var KAMAP_RECT_QUERY = 1; function kaQuery( oKaMap, type )
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
	
	</table>
    <p>

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/**********************************************************************
 *
 * $Id: overview-summary-kaQuery.js.html,v 1.1 2006/03/15 15:56:58 pspencer Exp $
 *
 * purpose: a simple tool for supporting queries.  It just provides
 *          the user interface for defining the query point or 
 *          area and defers the actual query to the application
 *
 * author: Paul Spencer (pspencer<span class="attrib">@dmsolutions</span>.ca)
 *
 * TODO:
 * 
 *   - implement a sample backend for query code
 *
 **********************************************************************
 *
 * Copyright (c) 2005, DM Solutions Group Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 *
 **********************************************************************
 *
 * To use this tool:
 * 
* 1) add a script tag to your page
 * 
 * &lt;script type="text/javascript" src="kaQuery.js"&gt;&lt;/script&gt;
 * 
 * 2) create a new instance of kaQuery
 * 
 * myKaQuery = new kaQuery( myKaMap, KAMAP_RECT_QUERY );
 * 
 * 3) provide some way of activating it.  This example would allow switching
 *    between querying and navigating.
 * 
 * &lt;input type="button" name="navigate" value="Navigate"
 *  onclick="myKaNavigator.activate()"&gt;
 * &lt;input type="button" name="query" value="Query"
 *  onclick="myKaQuery.activate()"&gt;
 * 
 * 4) listen for the query event 
 * 
 * myKaMap.registerForEvent( KAMAP_QUERY, null, myQuery );
 * 
 * 5) and do something when the user requests a query
 * 
 * function myQuery( eventID, queryType, coords )
 * {
 *     alert( "QUERY: " + queryType + " " + coords );
 * }
 * 
 * Querying actually does nothing except generate a KAMAP_QUERY event with 
 * the query type and coordinates passed as parameters to the event handler
 *
 * Signature of the query event handler is:
 *
 * function myQueryHandler( eventID, queryType, queryCoords )
 *
 * eventID: int, KAMAP_QUERY
 *
 * queryType: int, one of KAMAP_POINT_QUERY or KAMAP_RECT_QUERY
 *
 * queryCoords: array, array of two or four floating point coordinates
 *              depending on the query type
 *
 * You can affect the style of the zoom box by changing oQuery.domObj.style as
 * you would with any other HTML element (it's a div).
 *
 *****************************************************************************/</span>

<span class="comment">// the query event id</span>
var KAMAP_QUERY = gnLastEventId ++;

<span class="comment">// human names for the query types</span>
var KAMAP_POINT_QUERY = 0;
var KAMAP_RECT_QUERY = 1;

<span class="comment">/**
 * kaQuery constructor
 *
 * construct a new kaQuery object of a given type for a given kaMap instance
 *
 * oKaMap - a kaMap instance
 *
 * type - int, one of KAMAP_POINT_QUERY or KAMAP_RECT_QUERY.  If the type is
 *        KAMAP_POINT_QUERY then only point queries are allowed.  If the type
 *        is KAMAP_RECT_QUERY then point or rectangle queries are possible.
 */</span>
<span class="reserved">function</span> kaQuery( oKaMap, type ) {
    kaTool.apply( <span class="reserved">this</span>, [oKaMap] );
    <span class="reserved">this</span>.name = <span class="literal">'kaQuery'</span>;
    <span class="reserved">this</span>.cursor = <span class="literal">'help'</span>;
    
    <span class="comment">//this is the HTML element that is visible</span>
    <span class="reserved">this</span>.domObj = document.createElement( <span class="literal">'div'</span> );
    <span class="reserved">this</span>.domObj.style.position = <span class="literal">'absolute'</span>;
    <span class="reserved">this</span>.domObj.style.top = <span class="literal">'0px'</span>;
    <span class="reserved">this</span>.domObj.style.left = <span class="literal">'0px'</span>;
    <span class="reserved">this</span>.domObj.style.width = <span class="literal">'1px'</span>;
    <span class="reserved">this</span>.domObj.style.height = <span class="literal">'1px'</span>;
    <span class="reserved">this</span>.domObj.style.zIndex = 100;
    <span class="reserved">this</span>.domObj.style.visibility = <span class="literal">'hidden'</span>;
    <span class="reserved">this</span>.domObj.style.border = <span class="literal">'1px solid red'</span>;
    <span class="reserved">this</span>.domObj.style.backgroundColor = <span class="literal">'white'</span>;
    <span class="reserved">this</span>.domObj.style.opacity = 0.50;
    <span class="reserved">this</span>.domObj.style.mozOpacity = 0.50;
    <span class="reserved">this</span>.domObj.style.filter = <span class="literal">'Alpha(opacity=50)'</span>;
    <span class="reserved">this</span>.kaMap.theInsideLayer.appendChild( <span class="reserved">this</span>.domObj );

    <span class="reserved">this</span>.startx = null;
    <span class="reserved">this</span>.starty = null;
    <span class="reserved">this</span>.endx = null;
    <span class="reserved">this</span>.endy = null;
    <span class="reserved">this</span>.bMouseDown = false;
    
    <span class="reserved">this</span>.type = type;
    
    <span class="reserved">for</span> (var p in kaTool.<span class="reserved">prototype</span>) {
        <span class="reserved">if</span> (!kaQuery.<span class="reserved">prototype</span>[p])
            kaQuery.<span class="reserved">prototype</span>[p]= kaTool.<span class="reserved">prototype</span>[p];
    }
};

<span class="comment">/*
 * draw a box representing the query region.
 *
 * kaQuery maintains the query region in four variables.  The variables are
 * assumed to be in pixel coordinates and are used to position the box.  If
 * any of the coordinates are null, clear the query box.
 */</span>
kaQuery.<span class="reserved">prototype</span>.drawZoomBox = <span class="reserved">function</span>() {
    <span class="reserved">if</span> (<span class="reserved">this</span>.startx == null || <span class="reserved">this</span>.starty == null ||
        <span class="reserved">this</span>.endx == null || <span class="reserved">this</span>.endy == null ) {
        <span class="reserved">this</span>.domObj.style.visibility = <span class="literal">'hidden'</span>;
        <span class="reserved">this</span>.domObj.style.top = <span class="literal">'0px'</span>;
        <span class="reserved">this</span>.domObj.style.left = <span class="literal">'0px'</span>;
        <span class="reserved">this</span>.domObj.style.width = <span class="literal">'1px'</span>;
        <span class="reserved">this</span>.domObj.style.height = <span class="literal">'1px'</span>;
        <span class="reserved">return</span>;
    }
    
    <span class="reserved">this</span>.domObj.style.visibility = <span class="literal">'visible'</span>;
    <span class="reserved">if</span> (<span class="reserved">this</span>.endx &lt; <span class="reserved">this</span>.startx) {
        <span class="reserved">this</span>.domObj.style.left = (<span class="reserved">this</span>.endx - <span class="reserved">this</span>.kaMap.xOrigin) + <span class="literal">'px'</span>;
        <span class="reserved">this</span>.domObj.style.width = (<span class="reserved">this</span>.startx - <span class="reserved">this</span>.endx) + <span class="literal">"px"</span>;
    } <span class="reserved">else</span> {
        <span class="reserved">this</span>.domObj.style.left = (<span class="reserved">this</span>.startx - <span class="reserved">this</span>.kaMap.xOrigin) + <span class="literal">'px'</span>;
        <span class="reserved">this</span>.domObj.style.width = (<span class="reserved">this</span>.endx - <span class="reserved">this</span>.startx) + <span class="literal">"px"</span>;
    }

    <span class="reserved">if</span> (<span class="reserved">this</span>.endy &lt; <span class="reserved">this</span>.starty) {
        <span class="reserved">this</span>.domObj.style.top = (<span class="reserved">this</span>.endy - <span class="reserved">this</span>.kaMap.yOrigin) + <span class="literal">'px'</span>;
        <span class="reserved">this</span>.domObj.style.height = (<span class="reserved">this</span>.starty - <span class="reserved">this</span>.endy) + <span class="literal">"px"</span>;
    } <span class="reserved">else</span> {
        <span class="reserved">this</span>.domObj.style.top = (<span class="reserved">this</span>.starty - <span class="reserved">this</span>.kaMap.yOrigin) + <span class="literal">'px'</span>;
        <span class="reserved">this</span>.domObj.style.height = (<span class="reserved">this</span>.endy - <span class="reserved">this</span>.starty) + <span class="literal">"px"</span>;
    }
};

<span class="comment">/**
 * kaQuery.onmouseout( e )
 *
 * called when the mouse leaves theInsideLayer.  Terminate the query
 *
 * e - object, the event object or null (in ie)
 */</span>
kaQuery.<span class="reserved">prototype</span>.onmouseout = <span class="reserved">function</span>(e) {
    e = (e)?e:((event)?event:null);
    <span class="reserved">if</span> (!e.target) e.target = e.srcElement;
    <span class="reserved">if</span> (e.target.id == <span class="reserved">this</span>.kaMap.domObj.id) {
        <span class="reserved">this</span>.bMouseDown = false;
        <span class="reserved">this</span>.startx = <span class="reserved">this</span>.endx = <span class="reserved">this</span>.starty = <span class="reserved">this</span>.endy = null;
        <span class="reserved">this</span>.drawZoomBox();
        <span class="reserved">return</span> kaTool.<span class="reserved">prototype</span>.onmouseout.apply(<span class="reserved">this</span>, [e]);
    }
};

<span class="comment">/**
 * kaQuery.onmousemove( e )
 *
 * called when the mouse moves over theInsideLayer.
 *
 * e - object, the event object or null (in ie)
 */</span>
kaQuery.<span class="reserved">prototype</span>.onmousemove = <span class="reserved">function</span>(e) {
    e = (e)?e:((event)?event:null);
    
    <span class="reserved">if</span> (!<span class="reserved">this</span>.bMouseDown) {
        <span class="reserved">return</span> false;
    }
    
    <span class="reserved">if</span> (<span class="reserved">this</span>.type == KAMAP_RECT_QUERY) {
        var aPixPos = <span class="reserved">this</span>.adjustPixPosition( e.clientX, e.clientY );
        
        <span class="reserved">this</span>.endx=-aPixPos[0];
        <span class="reserved">this</span>.endy=-aPixPos[1];
        
        <span class="reserved">this</span>.drawZoomBox();
    }
    <span class="reserved">return</span> false;
}
;
<span class="comment">/**
 * kaQuery.onmousedown( e )
 *
 * called when a mouse button is pressed over theInsideLayer.
 *
 * e - object, the event object or null (in ie)
 */</span>
kaQuery.<span class="reserved">prototype</span>.onmousedown = <span class="reserved">function</span>(e) {
    e = (e)?e:((event)?event:null);
    <span class="reserved">if</span> (e.button==2) {
        <span class="reserved">return</span> <span class="reserved">this</span>.cancelEvent(e);
    } <span class="reserved">else</span> {
        <span class="reserved">if</span> (<span class="reserved">this</span>.kaMap.isIE4) document.onkeydown = kaTool_redirect_onkeypress;
        document.onkeypress = kaTool_redirect_onkeypress;
        
        <span class="reserved">this</span>.bMouseDown=true;
        
        var aPixPos = <span class="reserved">this</span>.adjustPixPosition( e.clientX, e.clientY );
        <span class="reserved">this</span>.startx=<span class="reserved">this</span>.endx=-aPixPos[0];
        <span class="reserved">this</span>.starty=<span class="reserved">this</span>.endy=-aPixPos[1];
        
        <span class="reserved">this</span>.drawZoomBox();
        
        e.cancelBubble = true;
        e.returnValue = false;
        <span class="reserved">if</span> (e.stopPropogation) e.stopPropogation();
        <span class="reserved">if</span> (e.preventDefault) e.preventDefault();
        <span class="reserved">return</span> false;
    }
};

<span class="comment">/**
 * kaQuery.onmouseup( e )
 *
 * called when a mouse button is clicked over theInsideLayer.
 *
 * e - object, the event object or null (in ie)
 */</span>
kaQuery.<span class="reserved">prototype</span>.onmouseup = <span class="reserved">function</span>(e) {
    e = (e)?e:((event)?event:null);
    
    var type = KAMAP_POINT_QUERY;
    var start = <span class="reserved">this</span>.kaMap.pixToGeo( -<span class="reserved">this</span>.startx, -<span class="reserved">this</span>.starty );
    
    var coords = start;
    <span class="reserved">if</span> (<span class="reserved">this</span>.startx!=<span class="reserved">this</span>.endx&amp;&amp;<span class="reserved">this</span>.starty!=<span class="reserved">this</span>.endy) {
        type = KAMAP_RECT_QUERY;
        coords = start.concat(<span class="reserved">this</span>.kaMap.pixToGeo( -<span class="reserved">this</span>.endx, -<span class="reserved">this</span>.endy ));
        <span class="reserved">if</span>(coords[2] &lt; coords[0]) {
            <span class="comment">//minx gt maxx than I invert values</span>
            var minx = coords[2];
            var maxx = coords[0];
            coords[0] = minx;
            coords[2] = maxx;
        }
        <span class="reserved">if</span>(coords[1] &lt; coords[3]){
            <span class="comment">//miny gt maggiore than I invert values</span>
            var miny = coords[1];
            var maxy = coords[3];
            coords[3] = miny;
            coords[1] = maxy;
        }
    }
    <span class="reserved">this</span>.kaMap.triggerEvent(KAMAP_QUERY, type, coords);
    
    <span class="reserved">this</span>.startx = <span class="reserved">this</span>.endx = <span class="reserved">this</span>.starty = <span class="reserved">this</span>.endy = null;
    <span class="reserved">this</span>.drawZoomBox();
        
    <span class="reserved">return</span> false;
};</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b>ka-Map</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Wed Mar 15 10:50:59 2006</div>
</body>
</html>
